package com.bhs.sansonglogistics.base;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.bhs.sansonglogistics.bean.Driver;
import com.bhs.sansonglogistics.bean.DriverDao;

@Database(entities = { Driver.class }, version = 1,exportSchema = false)
public  abstract class AppDatabase extends RoomDatabase {
    private static final String DB_NAME = "Database.db";
    private static volatile AppDatabase instance;

    public static synchronized AppDatabase getInstance(Context context) {
        if (instance == null) {
            instance = create(context);
        }
        return instance;
    }

    private static AppDatabase create(final Context context) {
        return Room.databaseBuilder(
                context,
                AppDatabase.class,
                DB_NAME).build();
    }

    public abstract DriverDao getDriverDao();
}
